import {get, post} from "~/api/request";
import type {BlogForgetForm, BlogLoginForm, BlogRegisterForm, SendCodeBo,} from "./types";

// 社会化登录
export const socialLogin = async (source: string) => {
    const res = await post(`/blog-web/oauth/render/${source}`);
    return res.data;
};

// 登录
export const login = async (data: BlogLoginForm) => {
    return await post("/blog-web/oauth/login",
        false, data, true);
};
// 邮箱验证码登录
export const emailCodeLogin = async (data: BlogLoginForm) => {
    return await post("/blog-web/oauth/emailCodeLogin", false, data, true);
};
// 登出
export const logout = async () => {
    return await post("/blog-web/oauth/logout");
};
// 发送验证码
export const sendCode = async (data: SendCodeBo) => {
    return await post("/blog-web/oauth/sendCode", false, data);
};
// 注册
export const register = async (data: BlogRegisterForm) => {
    return await post("/blog-web/oauth/register", false, data);
};
// 忘记密码
export const forgetPwd = async (data: BlogForgetForm) => {
    return await post("/blog-web/oauth/forgetPwd", false, data);
};

// 查询用户信息
export const queryBlogUserInfo = async () => {
    const res = await get("/blog-web/oauth/getBlogUserInfo", true);
    return res.data;
};
// 查询博主信息
export const queryBlogAuthorInfo = async () => {
    return await get("/blog-web/user/queryAuthor", false);
};
